<template>
	<view class="user">
		<view class="titleBox">
			<view class="statusBox" :style="{ height: statusHeight + 'px' }"></view>
			<view class="titleTxt">个人中心</view>
		</view>
		<!-- 底图 - 开始 -->
		<image class="user-header-image" :src="user_banner"></image>
		<!-- 底图 - 结束 -->

		<!-- 用户信息 - 开始 -->
		<view class="user-info-box">
			<u-avatar :size="60" class="avatarSize" :src="userInfo.avg ? userInfo.avg : user_avg" shape="square"></u-avatar>
			<view class="user-info-right">
				<view class="user-nickname">{{ userInfo.nickName ? userInfo.nickName : user_name }}</view>
				<u-button class="myBtn" type="primary" :plain="true" style="width: 8em" @click="handlePopShow">
					<u-icon name="edit-pen-fill" color="#3c9cff"></u-icon>
					修改信息
				</u-button>
			</view>
		</view>

		<!-- 用户信息 - 结束 -->

		<!-- 列表菜单 - 开始 -->
		<view class="user-activity-menu">
			<view class="menu-item">
				<view class="left">
					<view class="menu-name">企业信息</view>
				</view>
				<view class="menu-number">湖南天辰建设有限公司</view>
			</view>
			<view class="menu-item">
				<view class="left">
					<view class="menu-name">地区</view>
				</view>
				<view class="menu-number">长沙</view>
			</view>
			<view class="menu-item">
				<view class="left">
					<view class="menu-name">职位</view>
				</view>
				<view class="menu-number">施工队长</view>
			</view>
			<view class="menu-item">
				<view class="left">
					<view class="menu-name">联系电话</view>
				</view>
				<view class="menu-number">13337211791</view>
			</view>
			<view class="menu-item">
				<view class="left">
					<view class="menu-name">当前版本</view>
				</view>
				<view class="menu-number">{{ version }}</view>
			</view>
		</view>
		<view class="p30">
			<u-button class="bottomBtn" type="info" @click="goPage('login/index')">退出登录</u-button>
		</view>
		<!-- 列表菜单 - 结束 -->
	</view>
</template>

<script>
export default {
	data() {
		return {
			version: '1.0.0',
			user_banner: '../../static/index_banner.png',
			user_avg: '../../static/default.jpeg',
			user_name: '张三',
			userInfo: {},
			popShow: false,
			statusHeight: undefined
		};
	},
	created() {
		let _this = this;
		uni.getSystemInfo({
			success: function (res) {
				// console.log('getSystemInfo', res);
				_this.version = res.appVersion;
			}
		});

		//获取底部菜单高度
		const windowInfo = uni.getWindowInfo();
		// console.log(windowInfo);
		const tabBarHeight = windowInfo.windowHeight - windowInfo.safeArea.bottom;
	},
	onShow() {
		this.statusHeight = uni.getStorageSync('systemHeight');
	},
	methods: {
		handlePopShow() {
			uni.navigateTo({
				url: './edit/edit'
			});
		},
		/* 跳转页面 */
		goPage(pageName) {
			switch (pageName) {
				default:
					uni.navigateTo({
						url: '/pages/' + pageName
					});
					break;
			}
		}
	}
};
</script>

<style>
page {
	background: #f4f4f4;
}
</style>

<style lang="scss" scoped>
.user {
	position: relative;

	.titleBox {
		width: 750rpx;
		color: #fff;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 999;
		// background-color: skyblue;
		.statusBox {
			width: 100%;
		}

		.titleTxt {
			width: 100%;
			height: 44px;
			line-height: 44px;
			text-align: center;
			font-size: 17px;
			// font-weight: 800;
		}
	}
	.user-header-image {
		width: 100%;
		height: 276rpx;
	}

	.p30 {
		padding: 30rpx;
	}

	.user-info-box {
		background: #ffffff;
		padding: 25rpx;
		margin: -80rpx 30rpx 20rpx 30rpx;
		position: relative;
		border-radius: 20rpx;
		display: flex;
		align-items: center;

		.user-info-right {
			display: flex;
			justify-content: space-between;
			flex: 1;
			align-items: center;
			// background-color: pink;

			.myBtn {
				border: none;
				width: 400rpx !important;
				display: flex;
				justify-content: flex-end;
			}
		}

		.user-avg {
			width: 100rpx;
			height: 100rpx;
			border-radius: 10rpx;
		}

		.user-nickname {
			margin-left: 20rpx;
			width: 100%;
		}
	}

	.user-recharge-wrapper {
		background: #ffffff;
		border-radius: 20rpx;
		padding: 30rpx;
		margin: 20rpx;

		.user-recharge-box {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 20rpx;

			.recharge-info {
				.info-title {
					color: #333;
					font-size: 28rpx;
					font-weight: bold;
				}

				.info-content {
					color: #999;
					font-size: 24rpx;
				}
			}

			.recharge-button {
				// background: #ff4131;
				color: #333;
				padding: 10rpx 20rpx;
				font-size: 22rpx;
				border-radius: 50rpx;
				flex-shrink: 0;
				border: 1rpx solid #dadbde;
			}
		}

		.recharge-user-money {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 20rpx;
			font-size: 26rpx;
			color: #333;

			.recharge-money {
				font-weight: bold;
				font-size: 30rpx;
			}

			.recharge-money::first-letter {
				font-size: 22rpx;
			}
		}
	}

	.bottomBtn {
		width: 690rpx;
		border-radius: 20rpx;
		position: fixed;
		bottom: calc(var(--window-bottom) + 60rpx);
		left: 0;
		right: 0;
		border: none;
	}

	.user-activity-menu {
		padding: 0 30rpx;
		padding-bottom: 10rpx;
		margin: 30rpx;
		margin-top: 20rpx;
		border-radius: 20rpx;
		background: #fff;

		.menu-item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 90rpx;
			border-bottom: 1rpx solid #e5e5e5;
			// background-color: skyblue;

			.left {
				display: flex;
				align-items: center;

				.menu-icon {
					width: 40rpx;
					height: 40rpx;
				}

				.menu-name {
					font-size: 28rpx;
					// margin-left: 20rpx;
					color: #333;
				}
			}

			.menu-number {
				font-size: 30rpx;
				color: #666666;
				letter-spacing: 2rpx;
			}
		}

		.menu-item:last-child {
			border-bottom: none;
		}
	}
}
</style>
